<template>
  <div v-loading="loading">
      <div class="w-index-home">
          <div class="w-plate-item" @click="goPage('/order/reservation')">
            <div class="count">{{data.yyNum || 0}}</div>
            <div class="title">今日预约</div>
          </div>
          <div class="w-plate-item" @click="goPage('/order/list')">
            <div class="count">{{data.odNum || 0}}</div>
            <div class="title">今日订单</div>
          </div>
          <div class="w-plate-item">
          <div class="count">￥{{ data.totalPrice || 0}}</div>
          <div class="title">订单总金额</div>
        </div>
      </div>
  </div>
</template>

<script>
import request from '@/utils/request';
  export default {
    data() {
      return {
        data: {},
        loading: true,
      }
    },
    mounted() {
      request.get('/dashboard-data').then((res)=> {
        if (res.data.result.resp_data) {
          let data = JSON.parse(res.data.result.resp_data);
          this.data = data;
        }
        this.loading = false;
      })
    },
    methods: {
      goPage(path) {
        let day =  `${new Date().getFullYear()}/${new Date().getMonth() + 1}/${new Date().getDate()}`;
        this.$router.push(path + '?day=' + encodeURI(day))
      },

    },
  }
</script>

<style lang="scss" scoped>
.w-index-home{
  justify-content: center;
  display: flex;
  margin-top: 20px;
}
  .w-plate-item{
    margin: 0 20px;
    background: #7266ba;
    color: #fff;
    flex: 1;
    text-align: center;
    padding: 40px;
    border-radius: 10px;
    &:hover{
      opacity: 0.9;
      cursor: pointer;
    }
    &:nth-child(3n-1){
      background-color: #1c84c6;
    }
    .count{
      font-size: 36px;
      font-weight: normal;
      margin-bottom: 10px;
    }
  }
</style>